package models.user;

import javax.persistence.*;

import java.sql.*;
import java.sql.Blob;
import javax.sql.*;

import controllers.Application;

import java.math.*;
import java.util.*;
import java.util.Date;

import play.db.jpa.Model;
import play.cache.Cache;
import play.db.jpa.*;
import play.mvc.Scope;

/**
 * 客户信息表
 * 
 * @author yechao
 * @date 2013年11月2日
 */
@Entity
@Table(name = "customer")
public class Customer extends Model {
	/**
	 * 客户状态
	 */
	@Column(name = "status")
	public Integer status;

	/**
	 * 登录名
	 */
	@Column(name = "login_name", length = 30)
	public String loginName;

	/**
	 * 登录密码
	 */
	@Column(name = "login_password", length = 30)
	public String loginPassword;

	/**
	 * 客户创建时间
	 */
	@Column(name = "created_time")
	public Date createdTime;

	/**
	 * 客户姓名 不管中英文
	 */
	@Column(name = "full_name", length = 30)
	public String fullName;

	/**
	 * 客户地址
	 */
	@Column(name = "address", length = 100)
	public String address;

	/**
	 * 客户联系Email
	 */
	@Column(name = "email", length = 20)
	public String email;
	/**
	 * 客户电话号码
	 */
	@Column(name = "phone_number", length = 30)
	public String phoneNumber;

	/**
	 * 客户选择语言
	 */
	@Column(name = "language", length = 30)
	public String language;

	/**
	 * 根据登录名查找客户
	 * 
	 * @return
	 */
	public static Customer findCustomerByLoginName(String loginName) {
		return Customer.find("loginName = ?", loginName).first();
	}
}
